home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 6 / QRZ Ham Radio Callsign Database - Volume 6.iso / pc / files / p_msys / msys116.exe / HAPNMSYS.COM / HAPN-API.DOC next >
Encoding:
Text File  |  1991-01-14  |  14.0 KB  |  442 lines

  1.  
  2.  
  3. HAPN1.SYS DEVICE DRIVER
  4.  
  5.  
  6.  
  7. (C) Copyright Hamilton and Area Packet Network 1990
  8.  
  9.  
  10.  
  11. DESCRIPTION
  12.  
  13.  
  14. HAPN1.SYS is a  device driver that  supports the  8273 HDLC controller on the
  15. HAPN-1 adapter. In order to use it, it must be defined in the DOS  CONFIG.SYS
  16. file. DOS will then load it when the system is booted.
  17.  
  18. The  CONFIG.SYS entry appears as follows, where  items within square  brakets
  19. are optional:
  20.  
  21. device=[d:\path\]hapn1.sys [base=bbb][,irq=i][,cts=xx][,ttsiz=z]
  22.                            [,rxbuffers=rr][,txbuffers=tt]
  23.                            [,reserve=y/n][,pri=n][,tim=alt]
  24.  
  25. where bbb is the adapter 8273 base address (in hex) (i.e. 310).
  26.           The default value is 310.
  27.         i is the IRQ level. Values may be 0 through 7, and the
  28.           default value is 2.
  29.        rr is the number of Rx buffers to allocate. Minimum
  30.           number is 10, maximum number is 99, default number is 25.
  31.        tt is the number of Tx buffers to allocate. Minimum
  32.           number is 10, maximum number is 99, default number is 15.
  33.        xx is the clear-to-send delay in timer ticks (55 ms).
  34.           Values are 0 to 99, with default value 0.
  35.         z is the size of the trace table in kbytes. May be between
  36.           1 and 9. The default value is 4. Set it smaller to conserve
  37.           memory and larger to do datastream debugging.
  38.     pri=n (priority=no) By default the driver will change the priority
  39.           on the PC's interrupt controller so that the adapter interrupt
  40.           has the highest priority. This parameter tells the driver to
  41.           leave the interrupt controller priority setting alone. Use
  42.           this parameter when you have more than one adapter installed,
  43.           to help you manage the interrupt priorities. If the adapter
  44.           interrupt priority is not high enough, you will get numerous
  45.           interrupt overruns and underruns.
  46.   tim=alt tells the driver to use int 1c (hex) for the timer tick
  47.           interrupt instead of int 8. Int 8 is generally more reliable
  48.           when programs are run that use the timer tick interrupt but
  49.           do not share it properly; however in some cases it may be
  50.           desired to use int 1c instead.
  51.  
  52. The  device  driver contains all  the HAPN-1 adapter hardware  specific  code
  53. (level 1). It is used by M25.COM, which provides the AX.25 support (level 2).
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64. HAPN1.SYS Device Driver                                                     1
  65.  
  66.  
  67. PROGRAMMING INTERFACE
  68.  
  69.  
  70. Although  the driver may be opened as a DOS file,  it  does  not provide  I/O
  71. services via  DOS. This  is because DOS is not re-entrant, and  M25  must get
  72. access to the HAPN-1 driver from the timer tick  interrupt. If the timer tick
  73. interrupt  occurs while  an application program  is  accessing  DOS  for some
  74. function, and M25 tried to access HAPN1.SYS via DOS,  the system would crash.
  75. Therefore, an alternate means is  provided for programs such as M25 to access
  76. the functions within HAPN1.SYS without using DOS.
  77.  
  78. Programs wishing to access HAPN1.SYS directly may do so as follows:
  79.  
  80. 1.  Issue DOS OPEN to file with name  "HAPN1-A1" for adapter 1 and "HAPN1-A2"
  81.     for adapter 2.
  82.  
  83. 2.  Using  the handle returned from the open, issue  a  DOS IOCTL  READ for 4
  84.     bytes  of data. The 4 bytes are the long address of the HAPN1.SYS program
  85.     interface.
  86.  
  87. 3.  Issue DOS CLOSE.
  88.  
  89. The interface is then  accessed by  loading  a request  code in ah  register,
  90. possibly loading other registers,  and issuing a far call to the api address.
  91. From assembler this  is simply done by a call  instruction.  Other  languages
  92. must  provide a means to  load  registers  (including segment  registers) and
  93. issue  a far call.  (CI C/86 provides a  function  called farcall  which does
  94. this.)
  95.  
  96. The api function code goes  in ah for every call.  For most calls, a  port id
  97. goes in al. Port ids are  integers starting with  0.  Use  the "Get number of
  98. ports..." api function call to find out how  many ports  are supported by the
  99. driver. If you  use an invalid port id, calls to the  api will do nothing and
  100. return error if possible. (Note: the HAPN-1  supports only one port,  port 0.
  101. However multi-ported adapters may be available in the future.)
  102.  
  103.  
  104.  
  105. Activate Driver
  106.  
  107.  
  108. Load  ah  with 0  and call the api.  The  driver will be  activated and start
  109. receiving  packets. If  the  driver is  already active, the  8273  port B  is
  110. updated. There is no return code.
  111.  
  112.  
  113.  
  114. De-activate Driver
  115.  
  116.  
  117. Load ah with 1 and call the  api. The  driver will be  de-activated.  If  the
  118. driver is already inactive, -1 is returned in AX, otherwise 0 is returned.
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128. HAPN1.SYS Device Driver                                                     2
  129.  
  130.  
  131. Read a Frame
  132.  
  133.  
  134. Load ah with 2, load es:di  with the address of  a  buffer,  load cx with the
  135. size of the  buffer,  and load al with the port number.  Call  the api.  If a
  136. frame  is available, it will be  moved to your buffer and the number of bytes
  137. returned in ax. If no frame is available,  ax will be returned with 0. If the
  138. frame is  larger than your buffer, only the amount requested will be returned
  139. and the rest discarded.  Use  the  "get maximum frame  size"  api function to
  140. find out the size of the HAPN-1 internal buffer.
  141.  
  142.  
  143.  
  144. Write a Frame
  145.  
  146.  
  147. Load ah with 3,  load es:di with the  address of the buffer, load cx with the
  148. length  of  data  in the buffer, and  load  al with  the port  number.  If  a
  149. transmit buffer is available, your frame will be copied in and the  number of
  150. bytes  returned in ax. If no  transmit  buffers  are  available,  ax will  be
  151. returned with 0. If your data is longer than the size of the transmit buffer,
  152. only the transmit buffer  length will be copied and transmitted, and the rest
  153. discarded.  In  this  case ax  will  contain  the  number of  bytes  actually
  154. accepted. Use the "get maximum frame size" api function  to find out the size
  155. of the HAPN-1 internal buffer.
  156.  
  157.  
  158.  
  159. Request Transmission
  160.  
  161.  
  162. Load ah with 4, and load al with the port number.  Call the  api.  Any frames
  163. in the Tx buffers will be transmitted. The RTS signal  will be  asserted, and
  164. the frames  transmitted after the clear-to-send delay number  of  timer ticks
  165. have  elapsed. (The CTS delay defaults to  0 or whatever was on the HAPN1.SYS
  166. command  line, and  may  be changed  using the "set  Clear-To-Send delay" api
  167. function.)  The driver does not test for carrier  detect before transmitting.
  168. It is the user's responsibility to do this and issue this api function at the
  169. appropriate time. If  necessary,  use  the  "get carrier  detect  state"  api
  170. function to test the channel.
  171.  
  172.  
  173.  
  174. Get Driver Status
  175.  
  176.  
  177. Load ah with 5 and call the api. On  return,  ax  will be 0 if  the driver is
  178. inactive, and 1 if the driver is active.
  179.  
  180.  
  181.  
  182. Get Trace Table Data
  183.  
  184.  
  185. Load ah  with 6,  load es:di with the  address of a  buffer, load cx with the
  186. size of the buffer,  and load  al with  the port  number.  Call  the api. The
  187. trace table will be returned in your buffer, up to the size passed in cx. The
  188. buffer  should  be  large  enough  for  the  whole  trace table, since  it is
  189. wrap-around. The size may be obtained  from  the  "get  trace table size" api
  190.  
  191.  
  192. HAPN1.SYS Device Driver                                                     3
  193.  
  194.  
  195. function,  described below.  The  trace table includes  a 4-byte  header. The
  196. header  consists of 2 words, the first being the size of the data area of the
  197. trace table, and the second being the offset to the  next  byte to use in the
  198. data area.
  199.  
  200.  
  201.  
  202. Get Statistical Counters
  203.  
  204.  
  205. Load ah with 7, load es:di with the address of a buffer, and load cx with the
  206. size of the  buffer,  and load al with  the port  number.  Call the  api. The
  207. statistical counters  will be returned in your buffer, up to the size  passed
  208. in cx. The statistical counters are all long (4 bytes), and the buffer should
  209. be 100 bytes (i.3. 25 counters).
  210.  
  211.  
  212.  
  213. Get Carrier Detect State
  214.  
  215.  
  216. Load ah with 8, and  load  al with the port number.  Call the api. On return,
  217. ax will be 0 if there is no carrier detect, 1 if there is carrier detect, and
  218. -1 if the status cannot be determined.  Indeterminant  carrier  detect occurs
  219. when the driver is transmitting and  cannot  test the channel. In this  case,
  220. the application should interpret the channel as busy.
  221.  
  222.  
  223.  
  224. Set 8273 Port B
  225.  
  226.  
  227. Load ah with 9, put the port B state in cl, and load al with the port number.
  228. Call  the api.  For the  change  to become  effective, the adapter  should be
  229. activated  after changing port B.  (Activating the driver when it is  already
  230. active is OK and will do nothing except reset port B.)
  231.  
  232.  
  233.  
  234. Get Trace Table Size
  235.  
  236.  
  237. Load ah with 10 and load al with  the port number.  Call the  api. On return,
  238. ax will contain the trace table size, including the header.
  239.  
  240.  
  241.  
  242. Set Clear-To-Send Delay
  243.  
  244.  
  245. Load  ah with 11, put the CTS delay in cx, and  load al with the port number.
  246. Call the api. The CTS delay is measured in timer ticks, where one tick equals
  247. 55  milliseconds.  Note that the default  value is  zero (no delay) which  is
  248. only suitable where a hardware CTS is available. Otherwise, a value between 2
  249. and 6 is suitable for most rigs. (Note that when the delay is not 0, there is
  250. uncertainty  of up to one tick, which  is the time  between when the transmit
  251. order was received and the next timer tick,  so  use  the next higher value.)
  252. The  CTS delay  may  also be set as one of  the parameters when the driver is
  253. installed, in which case it will override the default value of zero.
  254.  
  255.  
  256. HAPN1.SYS Device Driver                                                     4
  257.  
  258.  
  259. Reset the 8273
  260.  
  261.  
  262. Load ah with 12, and load al with the  port number.  Call  the  api. The 8273
  263. will be reset.
  264.  
  265.  
  266.  
  267. Get HAPN-1.SYS size
  268.  
  269.  
  270. Load  ah with 13  and call the api. On  return,  ax will contain the size the
  271. driver occupies in memory.
  272.  
  273.  
  274.  
  275. Get transmitter status
  276.  
  277.  
  278. Load ah with  14, and load al  with the  port  number, and  call the api.  On
  279. return, ax will contain 0 if the transmitter is idle and 1 if the transmitter
  280. is busy.
  281.  
  282.  
  283.  
  284. Get number of ports for this driver
  285.  
  286.  
  287. Load ah with 15  and call the api. On return  ax will contain the  number  of
  288. ports available in this driver. Generally, the number of ports will be 1  but
  289. may be 2 or more.
  290.  
  291.  
  292.  
  293. Get maximum frame size
  294.  
  295.  
  296. Load ah with 16 and call the api. On return ax will contain the largest frame
  297. that can be received or transmitted  by this  driver.  The size  includes the
  298. ax.25 address field.
  299.  
  300.  
  301.  
  302. Get duplex mode
  303.  
  304.  
  305. Load ah with 17 and  call the api. On return ax will contain  0 for HDX and 1
  306. for FDX.
  307.  
  308.  
  309.  
  310. Query Rx Data Available
  311.  
  312.  
  313. Load  ah with 18 and the physical port id in al, and call the api.  On return
  314. ax will contain 0 if no Rx data is avilable, or  the length of the next frame
  315. if available.
  316.  
  317.  
  318.  
  319.  
  320. HAPN1.SYS Device Driver                                                     5
  321.  
  322.  
  323. Set duplex mode
  324.  
  325.  
  326. Load ah with 19 and cl with 0 (HDX) or 1 (FDX) and call the api.
  327.  
  328.  
  329.  
  330. Query reserve status
  331.  
  332.  
  333. Load ah  with  20 and call the api. If reserve=y was specified on the command
  334. line, 1 will be returned, otherwise 0 will be returned in ax.
  335.  
  336.  
  337.  
  338. Query if any Tx buffers available
  339.  
  340.  
  341. Load ah with 21 and al with the physical port id, and call the api.  If there
  342. is at least one Tx buffer free 1 is returned in ax, otherwise 0 is returned.
  343.  
  344.  
  345.  
  346. Get port name
  347.  
  348.  
  349. Load ah with 22 and al with the physical port  id, and place the address of a
  350. 30-byte buffer in es:di.  On return,  the  name of the port is  moved  to the
  351. buffer, as a null-terminated string.
  352.  
  353.  
  354.  
  355. TRACE TABLE DESCRIPTION
  356.  
  357.  
  358. The trace  table consists of a four byte header and  a quantity of data.  The
  359. header contains a 2-byte integer specifying  the  length of the  data,  and a
  360. 2-byte  integer  specifying the offset in the data area to the location where
  361. the next byte will be entered. The data area wraps around from the  bottom to
  362. the top, so the 2nd header integer points to where the oldest byte is. As new
  363. data is written over old data in  the table, the  oldest  entry may be partly
  364. overwritten, and will  therefore be  incomplete.  The table is initialized to
  365. nulls and nulls are interpreted as unused areas.
  366.  
  367. Each trace table entry has the following format:
  368.  
  369.     One byte code (alphabetic) defining the entry type.
  370.  
  371.     Four byte time stamp. This is present in all entries  except Rx  data and
  372.     Tx data. The time stamp is  a long integer and consists of the timer tick
  373.     counter in the driver.  Therefore, the  resolution is only in units of 55
  374.     ms. and cannot distinguish events between timer ticks.
  375.  
  376.     Zero or more bytes of data for the entry.
  377.  
  378.  
  379.  Code   Additional Data                          Description Of Entry
  380. ======  =======================================  ===========================
  381. B (42)  Rx-byte                                  8273 byte received
  382.  
  383.  
  384. HAPN1.SYS Device Driver                                                     6
  385.  
  386.  
  387. C (43)                                           8273 Rx command issued
  388. D (44)  Tx-byte                                  8273 byte transmitted
  389. E (45)  8273-stat-reg hapn1-stat-1 hapn1-stat-2  8273 Rx results malfunction
  390. F (46)                                           Timer: Raise RTS
  391. G (47)                                           HAPN-1 activate driver
  392. H (48)                                           8273 Tx timeout error
  393. K (4B)                                           HAPN-1 deactivate driver
  394. M (4D)                                           Disable Rx before Tx
  395. P (50)                                           8273 reset
  396. Q (51)                                           Enable 8273 rcv after reset
  397. R (52)                                           TxInt: Rx command issued
  398. S (53)  8273-status-reg                          8273 unknown interrupt
  399. T (54)                                           8273 Rx timeout error
  400. X (58)  8273-ric rx-len-lsb rx-len-msb ctrl-byte 8273 Rx result
  401. Y (59)  8273-tic                                 8273 Tx result
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448. HAPN1.SYS Device Driver                                                     7
  449.